export default{
    formatCoupons:function(item){
        //名称修改
        var coupons_name_len = 6;
        //优惠券名称
        item.couponsName = item.couponsName.length > coupons_name_len ? item.couponsName.substr(0,coupons_name_len) + "..." : item.couponsName;
        //使用限额
        if(item.quota == 0){
            item.useCondition = "";
        }else{
            item.useCondition = "满"+(item.quota/100)+"使用";
        }
        //使用日期
        if(item.endDate != null && item.endDate != ""){
            item.endDate = item.endDate.substr(5,5);
        }else{
            item.endDate = " 无限";
        }

        if(item.thumb != null && item.thumb != ""){
            item.style = "background-image: url('"+item.thumb+"');";
        }
        
        if(item.price != null && item.price != "" && parseInt(item.price) > 0){
            
            item.classifyName = "¥"+ ( (parseFloat(item.price) / 100 ).toFixed(2) );
        }

        if(item.classify != null && item.classify != ""){
            if(item.classify == "cutprice") item.classifyName = "分享砍价";
        }

        if(item.classifyName == null || item.classifyName == undefined || item.classifyName == "undefined")item.classifyName = "免费领取";

        return item;
    },
    formatCouponsStore : function(item,listStore){
        item = this.formatCoupons(item);
        
        if(listStore!=null){
            for(var i = 0 ; i < listStore.length ; i++){
                
                if(item.storeId == listStore[i].storeId){
                    
                    item.storeName = (listStore[i].address == null || listStore[i].address == "") ? listStore[i].storeName : listStore[i].address ;
                    // item.storeLogo = listStore[i].storeLogo.indexOf("http") >= 0 ? listStore[i].storeLogo : (this.$global.website + listStore[i].storeLogo) ;
                    return item;
                }
            }
        }
        
        return item;
    }
};